define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'channeldetail/index',
                    add_url: 'channedetails/add',
                    edit_url: 'channedetails/edit',
                    del_url: 'channedetails/del',
                    multi_url: 'channedetails/multi',
                    table: 'channedetails',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                searchFormVisible: true,
                // searchFormTemplate:'customfromtpl',
                columns: [
                    [
                        // {checkbox: true},
                        // {field: 'id', title: __('Id'), operate:false},
                        {field: 'date', title: __('Date'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'channel_code', title: __('Channel_code'), operate:false},
                        {field: 'new_num', title: __('New_num'), operate:false},
                        {field: 'register_num', title: __('Register_num'), operate:false},
                        {field: 'register_rate', title: __('Register_rate'), operate:false},
                        {field: 'active_num', title: __('Active_num'), operate:false},
                        {field: 'not_new_active_num', title: __('Not_new_active_num'), operate:false},
                        {field: 'ip_num', title: __('Ip_num'), operate:false},
                        {field: 'login_active_num', title: __('Login_active_num'), operate:false},
                        {field: 'start_num', title: __('Start_num'), operate:false},
                        {field: 'hit_num', title: __('Hit_num'), operate:false}
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});